package com.javalong.affairs.module.main.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.javalong.affairs.R;
import com.javalong.affairs.base.utils.StringUtils;
import com.javalong.affairs.base.utils.TimeUtils;
import com.javalong.affairs.module.renwujinzhang.model.NoticeMsg;
import com.javalong.affairs.module.renwujinzhang.model.Task;

import org.w3c.dom.Text;

/**
 * Created by javalong on 2016/5/15.
 */
public class NewMsgView extends FrameLayout {
    private TextView tv_date;
    private TextView tv_title;
    private TextView tv_desc;
    private ImageView iv_left;
    private TextView tv_num;

    public NewMsgView(Context context) {
        super(context);
        init();
    }

    public NewMsgView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {
        LayoutInflater.from(getContext()).inflate(R.layout.view_newmsg, this);
        tv_date = (TextView) findViewById(R.id.tv_date);
        tv_desc = (TextView) findViewById(R.id.tv_desc);
        tv_title = (TextView) findViewById(R.id.tv_title);
        iv_left = (ImageView) findViewById(R.id.iv_left);
        tv_num = (TextView) findViewById(R.id.tv_num);
    }

    public void initWithData(NoticeMsg msgInfo) {
        tv_date.setText(TimeUtils.getFormatTime(msgInfo.getTime()));
        tv_desc.setText("任务内容：" + msgInfo.getContent());
        tv_title.setText(msgInfo.getType());
        if ("紧急待办任务".equals(msgInfo.getType())) {
            iv_left.setImageResource(R.drawable.new_msg_1);
        } else if ("待审核任务".equals(msgInfo.getType())) {
            iv_left.setImageResource(R.drawable.new_msg_2);
        } else if ("审核不通过任务".equals(msgInfo.getType())) {
            iv_left.setImageResource(R.drawable.new_msg_3);
        } else if ("新通知消息".equals(msgInfo.getType())) {
            iv_left.setImageResource(R.drawable.new_msg_4);
        } else if ("待监督任务".equals(msgInfo.getType())) {
            iv_left.setImageResource(R.drawable.new_msg_5);
        } else if ("待评审任务".equals(msgInfo.getType())) {
            iv_left.setImageResource(R.drawable.new_msg_6);
        }
        tv_num.setText("" + msgInfo.getNum());
    }
}
